package com.djy.shxt.nemt.api;

import com.djy.shxt.nemt.domain.ApiResult;
import com.djy.shxt.nemt.domain.UserInfo;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


/**
 * @author daijiyong
 */
@RestController
@RequestMapping(value = "/api/user")
@Api(tags = "测试接口4")
public class UserApi {

    private static final Logger log = LoggerFactory.getLogger(UserApi.class);

    /**
     * 测试内容
     *
     * @param unionid 测试内容
     * @return ApiResult
     */
    @GetMapping(value = "/info/hasDone/{unionid}")
    @ApiOperation(value = "测试内容", response = ApiResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unionid", value = "测试内容", dataType = "String", required = true),
    })
    public ApiResult isInfoDone(@PathVariable("unionid") String unionid) {
        ApiResult apiResult = ApiResult.success("测试内容，测试内容");
        apiResult.put("isInfoDone", false);
        return apiResult;
    }

    /**
     * 测试内容
     *
     * @param unionid  测试内容
     * @param userInfo 测试内容
     * @return ApiResult
     */
    @PostMapping(value = "/addOrSave/{unionid}")
    @ApiOperation(value = "测试内容", response = ApiResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unionid", value = "测试内容", dataType = "String", required = true),
    })
    public ApiResult addOrSaveInfo(@PathVariable("unionid") String unionid, UserInfo userInfo) {
        ApiResult apiResult = ApiResult.success("测试内容");
        log.info(unionid + userInfo.toString());
        apiResult.put("succes", true);
        return apiResult;
    }

    /**
     * 测试内容
     *
     * @param unionid 测试内容
     * @return ApiResult
     */
    @GetMapping(value = "/info/{unionid}")
    @ApiOperation(value = "测试内容", response = ApiResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unionid", value = "测试内容", dataType = "String", required = true),
    })
    public ApiResult getInfo(@PathVariable("unionid") String unionid) {
        ApiResult apiResult = ApiResult.success("测试内容");

        Map<String, Object> map = new HashMap<>();
        map.put("name", "测试内容");
        map.put("area", "测试内容");
        map.put("identity", "测试内容");
        map.put("school", "测试内容");
        map.put("grade", "测试内容");
        apiResult.put("userInfo", map);
        return apiResult;
    }


    /**
     * 测试内容
     *
     * @param unionid 测试内容
     * @return ApiResult
     */
    @GetMapping(value = "/member/{unionid}")
    @ApiOperation(value = "测试内容", response = ApiResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unionid", value = "测试内容", dataType = "String", required = true),
    })
    public ApiResult memberInfo(@PathVariable("unionid") String unionid) {
        ApiResult apiResult = ApiResult.success("测试内容");

        apiResult.put("isMember", false);
        return apiResult;
    }

}
